#!/bin/Rscript

on_100_20 <- read.table("on/profits.dat")$V1
op_100_20 <- read.table("rf/profits.dat")$V1
ut_100_20 <- read.table("ut/profits.dat")$V1

# Testes de hipoteses
print("100 us 1_5_10% 20% hi == on")
t.test(ut_100_20, on_100_20, paired=TRUE, var.equal=FALSE)
print("hi > on")
t.test(ut_100_20, on_100_20, paired=TRUE, var.equal=FALSE, alternative="less")

print("hi == op")
t.test(ut_100_20, op_100_20, paired=TRUE, var.equal=FALSE)
print("hi > op")
t.test(ut_100_20, op_100_20, paired=TRUE, var.equal=FALSE, alternative="less")

print("op == on")
t.test(op_100_20, on_100_20, paired=TRUE, var.equal=FALSE)
print("op > on")
t.test(op_100_20, on_100_20, paired=TRUE, var.equal=FALSE, alternative="less")


# >>>>>> Resumos dos profits
print(">>>>>>>> LUCROS 100 1_5_10% 20%")
paste("OP", mean(op_100_20), "[", 1.96*sd(op_100_20)/sqrt(length(op_100_20))+mean(op_100_20), ":", mean(op_100_20) - 1.96*sd(op_100_20)/sqrt(length(op_100_20)), "]")
paste("UT", mean(ut_100_20), "[", 1.96*sd(ut_100_20)/sqrt(length(ut_100_20))+mean(ut_100_20), ":", mean(ut_100_20) - 1.96*sd(ut_100_20)/sqrt(length(ut_100_20)), "]")
paste("ON", mean(on_100_20), "[", 1.96*sd(on_100_20)/sqrt(length(on_100_20))+mean(on_100_20), ":", mean(on_100_20) - 1.96*sd(on_100_20)/sqrt(length(on_100_20)), "]")


#>>>>>>>>> Ganhos para risco de 1_5_10% e 20%

gop_100_20 <- (op_100_20 - on_100_20) / abs(on_100_20)
gut_100_20 <- (ut_100_20 - on_100_20) / abs(on_100_20)

print(">>>> GANHOS 100 10%")
paste("Ganhos hi --> on", mean(ut_100_20 - on_100_20), " ", mean(gut_100_20), " [", 1.96*sd(gut_100_20)/sqrt(length(gut_100_20))+mean(gut_100_20), ":",  mean(gut_100_20) - 1.96*sd(gut_100_20)/sqrt(length(gut_100_20)), "]" )
print(paste(gut_100_20))

paste("Ganhos op --> on", mean(op_100_20 - on_100_20), " ", mean(gop_100_20), " [", 1.96*sd(gop_100_20)/sqrt(length(gop_100_20))+mean(gop_100_20), ":",  mean(gop_100_20) - 1.96*sd(gop_100_20)/sqrt(length(gop_100_20)), "]" )
print(paste(gop_100_20))

